package models_sports

import (
	"github.com/shopspring/decimal"
	pb "longmen/server/pkg/protobuf"
)

type FootballOdds struct {
	Id               int64           `json:"id" gorm:"primaryKey;type:bigint(20); comment:主键 "`
	MatchId          int             `json:"match_id" gorm:"index:idx_match_id;type:int(11);comment:比赛id"`
	CompanyId        int             `json:"company_id" gorm:"index:idx_company_id;type:int(11);comment:指数公司id"`
	ExponentialType  string          `json:"exponential_type"  gorm:"index:exponential_type;type:varchar(30);comment:指数类型：asia-亚盘、eu-欧赔、bs-大小球、cr-角球"`
	ExponentialScore string          `json:"exponential_score" gorm:"type:varchar(30);comment:进球比分 or 角球比(cr)，主队-客队"`
	MatchStatus      int             `json:"match_status"  gorm:"index:match_status;type:int(11);comment:比赛状态，详见状态码->比赛状态"`
	OddsStatus       int             `json:"odds_status" gorm:"index:odds_status;type:int(11);comment:是否封盘：1-封盘,0-未封盘"`
	Odds1            decimal.Decimal `json:"odds_1" gorm:"type:decimal(11, 3);comment:主胜/大球/大"`
	Odds2            decimal.Decimal `json:"odds_2"  gorm:"type:decimal(11, 3);comment:和局/盘口"`
	Odds3            decimal.Decimal `json:"odds_3" gorm:"type:decimal(11, 3);comment:客胜/小球/小"`
	ChangeTime       int64           `json:"change_time" gorm:"index:change_time;type:int(11);comment:变化时间"`
	CompetitionTime  string          `json:"competition_time" gorm:"type:varchar(30);comment:比赛进行时间"` //
}

func (o FootballOdds) GetProto() *pb.OddsItem {
	return &pb.OddsItem{
		Id:               o.Id,
		MatchId:          uint32(o.MatchId),
		CompanyId:        int32(o.CompanyId),
		ExponentialType:  o.ExponentialType,
		ExponentialScore: o.ExponentialScore,
		MatchStatus:      uint32(o.MatchStatus),
		OddsStatus:       uint32(o.OddsStatus),
		Odds1:            o.Odds1.String(),
		Odds2:            o.Odds2.String(),
		Odds3:            o.Odds3.String(),
		ChangeTime:       o.ChangeTime,
		CompetitionTime:  o.CompetitionTime,
	}
}
